import $app from '../$app';


export default {
	//专利详情 补正+OA 的表格栏目
	tabMcol(that) {
		let out = [{
				title: "期限",
				width: 150,
				render: (h, params) => {
					let {
						row: {
							time_limit,
							state, // 0未处理 1已经处理
						}
					} = params;

					return h(
						"div", {
							class: (state == 0 && "cRed")
						},
						time_limit
					);
				}
			},
			{
				title: "创建日期",
				width: 200,
				render: (h, params) => {
					let created_at = $app.toDateToMin(params.row.created_at);
					let out = [];
					out.push(h("span", created_at));
					return out;
				}
			},
			{
				title: "附件（点击查看）",
				render: (h, params) => {
					//goods_type:100实用新型、101外观设计、102发明
					let {
						goods_type,
						orderInfo,
						orLiInfo
					} = that;

					let {
						row: {
							type, //1补正, 2oa
							// 0未处理 1和2=》都是已处理，区别在于，一个是客户补的，一个是客服补的 
							// 对于用户 1和2显示的结果都一样
							state, //补正+OA都一样=》   0 未处理   1已处理   2客服修改已处理  
							note_file_path, //通知书文件
							
							main_file_path, //type=1时,补正书; type=2时,oa意见陈述书
							main_content_json, //自动化CPC提交的补正文件
							content_json,content_txt,

							
							// 五书
							instruction,
							instruction_abstract,
							claims,
							instruction_image,
							abstract_image,

							appe_brief_desc_path, //外观简要说明
							appe_request_path, //外观专利请求书
							appe_img_list, //外观图片

							


							bz_weituo, //代理委托书 补正OA都会有
							apply_path,//专利请求书


							compare_page_path, //对照页 补正OA都会有
							other_paths,//其他文件 补正OA都会有
						}
					} = params;

					let out = [
						h(
							"span", {
								class: " marginR20 "+ (state == 0 ? ' cRed' : ' c999 '),
								on: {
									click: () => {
										$app.fileNameAgainDown($app.getVal_fileUrl( note_file_path ), orderInfo, orLiInfo);
									}
								},
							},[
								h("i", {
									class: "iconfont marginR5 " + $app.fileIcon(note_file_path)
								}),
								h("span", {
									class: " textLine ",
								}, (type == 1 ? "补正 通知书" : "OA 通知书"))
							]
						)
						
					];


					//已经处理的东西
					if (state == 1 || state == 2) {

						// 最旧的数据=》补正+OA方式
						if ($app.getVal_fileUrl( main_file_path )) {
							out.push(
								h(
									"span", {
										on: {
											click: () => {
												$app.openWindow($app.getVal_fileUrl( main_file_path ));
											}
										},
										class: "lineH1d5 textLine cBlue marginR20  inlineBlock"
									},
									[
										h("i", {
											class: "iconfont marginR5 " + $app.fileIcon(main_file_path)
										}),
										h("span", (type == 1 ? "补正书" : "意见陈述书"))
									]
								)
							);
						}

						// 第二旧的数据=》补正+OA方式
						if ($app.judgeData(main_content_json)) { //补正
							out.push(
								h(
									"span", {
										on: {
											click: () => {
												if (type == 1) { //补正
													that.tow(main_content_json);
												} else { //OA
													that.iwR(main_content_json);
												}
											}
										},
										class: "lineH1d5 textLine cBlue marginR20  inlineBlock"
									},
									[
										h("i", {
											class: "iconfont marginR5 iconbuzheng"
										}),
										h("span", (type == 1 ? "已补正" : "已OA"))
									]
								)
							);
						}

						// 目前最新的数据=》补正+OA方式 =>以补正形式答复
						if ($app.judgeData(content_json)) { //补正
							out.push(
								h(
									"span", {
										on: {
											click: () => {
												that.tow_Kk(content_json);
											}
										},
										class: "lineH1d5 textLine cBlue marginR20  inlineBlock"
									},
									[
										h("i", {
											class: "iconfont marginR5 iconbuzheng"
										}),
										h("span", "以补正形式答复")
									]
								)
							);
						}
						// 目前最新的数据=》补正+OA方式 =>以OA形式答复
						if ($app.judgeData(content_txt)) { //补正
							out.push(
								h(
									"span", {
										on: {
											click: () => {
												that.iwR(content_txt);
											}
										},
										class: "lineH1d5 textLine cBlue marginR20  inlineBlock"
									},
									[
										h("i", {
											class: "iconfont marginR5 iconbuzheng"
										}),
										h("span", "以OA形式答复")
									]
								)
							);
						}

						let had_file_can_see=($app.getVal_fileUrl( appe_brief_desc_path )
							||$app.getVal_fileUrl( appe_request_path )
							||$app.getVal_fileUrl( instruction )
							||$app.getVal_fileUrl( instruction_abstract )
							||$app.getVal_fileUrl( claims )
							||$app.getVal_fileUrl( instruction_image )
							||$app.getVal_fileUrl( abstract_image )
							||$app.getVal_fileUrl( apply_path )
							||$app.getVal_fileUrl( bz_weituo )
							||$app.judgeData(compare_page_path)
							||$app.judgeData(other_paths)
							||$app.judgeData(appe_img_list)
						);
						if(had_file_can_see){
							out.push(
								h(
									"span", {
										on: {
											click: () => {
												that.kanFuJin(params.row);
											}
										},
										class: "lineH1d5 textLine cBlue   inlineBlock"
									},
									[
										h("i", {
											class: "iconfont marginR5 iconjiansuo"
										}),
										h("span", "附件")
									]
								)
							);
						}


					}

					return h("div", out);
				}
			},
			{
				title: "状态 / 操作",
				width: 110,
				render: (h, params) => {
					let {
						row: {
							id,
							type, //1补正, 2oa
							time_limit,//期限
							state // 0未处理 1已经处理
						}
					} = params;
					let out = "";

					//7待补正 10待OA
					let stateT=that.orderInfo.state;
					let state_name=that.orderInfo.state_name;


					if (state == 0) {
						out = h("div", [
							h(
								"Button", {
									class: "marginR10",
									props: {
										type: "primary",
										icon: "md-arrow-round-up",
										size: "small"
									},
									on: {
										click: () => {
											
											// orLiInfo.goods_type:  100实用新型、101外观设计、102发明
											// console.log('that = ',that.goods_type)
											let objTo = that.$refs['Box1'];
											if(stateT==7 && type==1){//补正
												objTo.cMox = true;
												objTo.bz_oz_type = type;
												objTo.bz_oz_id = id;
												objTo.time_limit=time_limit;
											}else if(stateT==10 && type==2){//OA
												objTo.cMox = true;
												objTo.bz_oz_type = type;
												objTo.bz_oz_id = id;
												objTo.time_limit=time_limit;
											}else{
												$app.alert('当前订单状态为 '+state_name,'无法'+(type == 1 ? '补正' : 'OA'));
											}


											
										}
									}
								},
								(type == 1 ? '补正' : 'OA')
							)
						]);
					} else {
						out = h(
							"div", {
								class: "cCCC"
							},
							type == 1 ? "已上传补正" : "已上传OA"
						);
					}

					return out;
				}
			}
		];
		return out;
	}
};
